<?php

//functie de numarare a paragrafelor identice adnotate de useri diferiti
function paragraph_number($identificator){
$total = mysql_query("SELECT COUNT(id_paragraph) FROM annotation WHERE id_paragraph=".$identificator);
$nr_paragrafe_adnotate = mysql_fetch_array($total);
return $nr_paragrafe_adnotate;
}

function select_paragraph($id) {
  
  $sql = "SELECT modified_text FROM annotation WHERE id_paragraph =" . $id;
  $result = mysql_query($sql);
  $rows = mysql_fetch_array($result);
  return $rows;
}

function getLastId() {
  $sql = "SELECT max(id_paragraph) FROM annotation";
  $result = mysql_query($sql);
  $lastId = mysql_fetch_array($result);
  return $lastId["max(id_paragraph)"];
}

function getFiveXMLSameType($id) {
  $i=1;
  $sql = "SELECT modified_text FROM annotation WHERE id_paragraph =" . $id;
  $result = mysql_query($sql);
  while($rows = mysql_fetch_array($result))
{
      $p[$i]=$rows['modified_text'];
      $i++;
}
 
     for($j = 1; $j < 6; $j++)
         $paragraf[$j]= $p[$j];
             
 return $paragraf;

}

//functie de "escape string" pentru interogarile MySQL
function escape_string($string) {
    if (get_magic_quotes_gpc()) {
		$string = stripslashes($string);
    }
    if (function_exists("mysql_real_escape_string")) {
		$string = mysql_real_escape_string($string);
    } else {
		$string = addslashes($string);
    }
    return $string;
}

?>
